package com.dream.wuliu.utils;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import com.dream.vo.api.ApiOrder;
import com.dream.vo.api.ApiOrderDetail;
import com.dream.vo.api.ApiSpinnerData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class GsonHelper {
	
	public static  List<ApiOrder> orderList(String gson){
		if(MyUtils.isBlank(gson)){
			return MyUtils.newArrayList();
		}
		Type type = new TypeToken<ArrayList<ApiOrder>>() { }.getType();
		return new Gson().fromJson(gson,type);
	}
	
	public static ApiOrderDetail orderDetail(String gson){
		if(MyUtils.isBlank(gson)){
			return new ApiOrderDetail();
		}
		return new Gson().fromJson(gson,ApiOrderDetail.class);
	}
	
	public static List<ApiSpinnerData> productCategory(String gson){
		
		if(MyUtils.isBlank(gson)){
			return MyUtils.newArrayList();
		}
		Type type = new TypeToken<ArrayList<ApiSpinnerData>>() { }.getType();
		return new Gson().fromJson(gson,type);
	}
	
}
